<?php
class News extends DataObject{
    static $db = array(
		'Title'		    => 'Varchar(255)',
        'Content'       => 'HTMLText',
        'ExternalLink'  => 'Varchar(255)'
    );
    
    static $has_one = array(        
		'Image'			=> 'Image',
		'NewsPage'		=> 'NewsPage',
    );
	
    function getCMSFields_forPopup() {		
        $fields = new FieldSet();        
        
        $fields->push(new TextField('Title', 'Title'));         
		$fields->push(new ImageField('Image', 'Image'));
        //$fields->push(new HtmlEditorField('Content', 'Content', 20));        
        $fields->push(new SimpleTinyMCEField('Content', 'Content', null, 20));
        $fields->push(new TextField('ExternalLink', 'External link'));
        
        return $fields;
    }

    function IntroText(){
        $intro = new Text();
        $intro->setValue($this->Content);
        
        return $intro->LimitWordCount(10);
    }
}